package com.daniu101.productbargan.controller;


import com.daniu101.productbargan.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

@Controller
@RequestMapping(value = "/product")
public class ProductController {

    @Autowired
    private IProductService productService;

    //跳入到 商品列表页面
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    public String list(){
        return "product/list";
    }

    //接受 商品图片
    @ResponseBody
    @RequestMapping(value = "/upload",method = RequestMethod.POST)
    public String upload(MultipartFile cover){

        if (cover.isEmpty()) {
            return "-1";
        }

        return productService.uploadCover(cover);
    }

}
